package com.asdc.autoscanfiles.controller;

import com.asdc.autoscanfiles.entity.Dict;
import com.asdc.autoscanfiles.service.DictService;
import com.asdc.autoscanfiles.utils.StaticUtils;
import org.apache.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author zhangbingyue
 * @Description //TODO $ 数据字典查询
 * @Date $ $
 * @Param $
 * @return $
 **/
@RestController
@RequestMapping("/api/dict")
public class DictController {

    @Resource
    public DictService dictService;


    @PostMapping("/getLevelByType")
    public List<Dict> getLevel(HttpServletRequest request) {
        List<Dict> dicts = null;
        String type = request.getParameter("type");
        Integer parentId = Integer.parseInt(request.getParameter("parentId"));
        if (!type.equals("")) {
            dicts = dictService.queryParentByType(type);
        } else {
            dicts = dictService.queryByType(StaticUtils.type3, parentId);
        }
        return dicts;
    }

}
